/**
 * @description array plat deep
 */

/**
 * @param arr array
 */
export function arrayFlattenDeep(arr: any[]): any[]{
  const result: any[] = [];

  arr.forEach(item => {
    if(Array.isArray(item)){
        result.push(...arrayFlattenDeep(item));
    } else {
        result.push(item);
    }
  });
  
  return result;
}


export function arrayFlattenDeep2(arr: any[]): any[]{
    let result: any[] = [];
  
    arr.forEach(item => {
      if(Array.isArray(item)){
        result = result.concat(...arrayFlattenDeep2(item));
      } else {
        result = result.concat(item);
      }
    });
    
    return result;
  }

// 功能测试
const testArray = [1,[2,['a',true],5],6];
console.log(arrayFlattenDeep2(testArray));